package com.leo;

import javafx.application.Application;
import javafx.application.HostServices;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

import java.net.URL;

/**
 * @ClassName SceneDemo
 * @Description
 * @Author wangss
 * @date 2020.05.16 21:24
 * @Version 1.0
 */
public class SceneDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        // 加载资源
        URL resource = getClass().getClassLoader().getResource("image/icon.png");
        String path = resource.toExternalForm();

        // 打开网页
        HostServices hostServices = getHostServices();
        hostServices.showDocument("http://www.baidu.com");

        Button button = new Button("开始");
//        button.setCursor(Cursor.MOVE);
        button.setCursor(Cursor.cursor(path));
        button.setPrefSize(200d, 200d);

        // 布局
        Group group = new Group();
        group.getChildren().add(button);

        // 场景
        Scene scene = new Scene(group);
        // 改变鼠标样式
        scene.setCursor(Cursor.HAND);
        primaryStage.setScene(scene);

        primaryStage.setTitle("scene");
        primaryStage.setWidth(500d);
        primaryStage.setHeight(500d);
        primaryStage.show();
    }
}
